//
//  AuthenVerifyMsgVM.swift
//  kxf
//
//  Created by Mac on 2024/3/28.
//

import Foundation
import UIKit
import SwiftUI

class AuthenVerifyMsgVM: UIView {
    
    var selfHeight = RegisterViewHeadTitleVM().selfHeight+RegisterInputVM().selfHeight*5
    var controller = WHBaseViewVC()
    
    override init(frame:CGRect){
        super.init(frame: CGRect.init(x: 0, y: frame.origin.y, width: SCREEN_WIDHT, height: selfHeight))
        self.backgroundColor = .white
        self.isUserInteractionEnabled = true
        
        initUI()
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy var msgTitleVm : RegisterViewHeadTitleVM = {
        let vm = RegisterViewHeadTitleVM.init(frame: CGRect.init(x: 0, y: 0, width: 0, height: 0))
        vm.titleLabel.text = "信息"
        return vm
    }()
    lazy var idNameVm : RegisterInputVM = {
        let vm = RegisterInputVM.init(frame: CGRect.init(x: 0, y: self.msgTitleVm.frame.maxY, width: 0, height: 0))
        vm.leftLabel.text = "证件姓名"
        vm.textField.placeholder = "请输入证件姓名"
        vm.textField.keyboardType = .default
        vm.maxLength = 30
        return vm
    }()
    lazy var idNoVm : RegisterInputVM = {
        let vm = RegisterInputVM.init(frame: CGRect.init(x: 0, y: self.idNameVm.frame.maxY, width: 0, height: 0))
        vm.leftLabel.text = "证件号码"
        vm.textField.placeholder = "请输入证件号码"
//        vm.textField.keyboardType = .default
        vm.maxLength = 30
        return vm
    }()
    
    lazy var bankNoVm : RegisterInputVM = {
        let vm = RegisterInputVM.init(frame: CGRect.init(x: 0, y: self.idNoVm.frame.maxY, width: 0, height: 0))
        vm.leftLabel.text = "银行卡号"
        vm.textField.placeholder = "请输入银行卡号"
        vm.maxLength = 30
        vm.textField.keyboardType = .numberPad
        return vm
    }()
    lazy var phoneVm : RegisterInputVM = {
        let vm = RegisterInputVM.init(frame: CGRect.init(x: 0, y: self.bankNoVm.frame.maxY, width: 0, height: 0))
        vm.leftLabel.text = "手机号"
        vm.textField.placeholder = "请输入手机号"
        vm.maxLength = 11
        vm.textField.keyboardType = .numberPad
        return vm
    }()
    lazy var bankBranchVm : RegisterInputVM = {
        let vm = RegisterInputVM.init(frame: CGRect.init(x: 0, y: self.phoneVm.frame.maxY, width: 0, height: 0))
        vm.leftLabel.text = "开户支行"
        vm.textField.placeholder = "请选择开户支行"
        vm.showArrowImg()
        vm.tapBlock = {()in
            let vc = AuthenBankBranchListVC()
            vc.tapBlock = {(dict)in
                AuthenMiniMsgModel.shareInstance.legalBankBranchCode = "\(dict["branchNo"]as? String ?? "")"
                AuthenMiniMsgModel.shareInstance.legalBankBranchName = "\(dict["branchBankName"]as? String ?? "")"
                self.bankBranchVm.setLabelContent(content: AuthenMiniMsgModel.shareInstance.legalBankBranchName)
            }
            self.controller.navigationController?.pushViewController(vc, animated: true)
        }
        return vm
    }()
}

extension AuthenVerifyMsgVM{
    func initUI() {
        addSubview(msgTitleVm)
        addSubview(idNameVm)
        addSubview(idNoVm)
        addSubview(bankNoVm)
        addSubview(phoneVm)
        addSubview(bankBranchVm)
        
    }
}
